import java.util.Random;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Random random = new Random();//生成随机数
        //Random random1 = new Random(132);
        // 这样产生的随机数不会变-都是第一次产生的
        int n = random.nextInt(100)+1;//(1-100)的随机数
        int op = 5;
        System.out.println("你有5次机会");
        do {
            System.out.print("输入数字:");
            int guess = scan.nextInt();
            if (guess == n){
                System.out.println("猜对了："+n);
                break;
            }
            else if (guess > n){
                System.out.println("猜大了!");
            }
            else if (guess < n){
                System.out.println("猜小了!");
            }
        }while((--op) != 0);
        if(op == 0){
            System.out.println("你失败了！");
        }
        else{
            System.out.println("恭喜你猜对了！");
        }
    }
}